package lab03.test03;

import java.io.*;

public class Test {
    public static void main(String[] args) throws IOException{
        File file =new File("D:\\dev\\实验.txt");
        //将B数组解码为字节数组
        byte b[]="北京欢迎你！".getBytes();
        try{
            FileOutputStream out =new FileOutputStream(file);
            out.write(b);
            out.close();
            FileInputStream in=new FileInputStream(file);
            int n=0;
            while( (n=in.read(b,0,2))!=-1){
                String Str =new String(b,0,n);
                System.out.println(Str);
             }
            FileWriter writer =new FileWriter("D:\\dev\\实验.txt",true);
            writer.write("我的学号是：1606101122");
            writer.close();
            int m=0;
           while ((m=in.read(b,0,2))!=-1){
               String Str =new String(b,0,n);
               System.out.println(Str);
           }
        }catch (Exception e){
            System.out.println(e);
        }


    }
}
